package com.ruoyi.wbk.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.wbk.config.CommonConfig;
import com.ruoyi.wbk.domain.ApplyFile;
import com.ruoyi.wbk.service.WbkApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api("wbk_test")
@RestController
@RequestMapping("/wbk/api")
public class WbkApiController extends BaseController {

    @Autowired
    private WbkApiService wbkApiService;

    @Autowired
    private CommonConfig config;

    @ApiOperation("测试")
    @GetMapping("/fff")
    public R<List<Map<String, String>>> userList() {
        List<Map<String, String>> fileMapList = wbkApiService.getFileMapList();
        return R.ok(fileMapList);
    }

    @ApiOperation("测试22")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list() {
        startPage();
        List<ApplyFile> list = wbkApiService.getFileEntityList();
        return getDataTable(list);
    }

    @ApiOperation("测试33")
    @PostMapping("/thirdDatasource")
    @ResponseBody
    public TableDataInfo thirdDatasource() {
        startPage();
        List<Map<String, String>> list = wbkApiService.thirdDatasource();
        return getDataTable(list);
    }



    @ApiOperation("测试nacos")
    @PostMapping("/testNacos")
    @ResponseBody
    public R<String> testNacos() {
        System.out.println(config.getTtName());
        return R.ok(config.getTtName());
    }

}
